<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php session_start();
include_once 'backend/breadcrumb.php';
include_once 'backend/select_task_list.php';
include_once 'backend/select_task.php';
include_once "backend/select_story.php";

$iterationId = isset($_GET['iter']) ? $_GET['iter'] : 0;

if($iterationId == 0){
	$iterationId = $story['iteration_id'];
}
?>
<html xmlns = "http://www.w3.org/1999/xhtml">
	<head>
		<title>
			Story
		</title>
		
		<script type="text/javascript" src="scripts/jquery-1.11.1.min.js"></script>		
		<script type="text/javascript" src="scripts/breadcrumb.js"></script>
		<script type="text/javascript" src="scripts/url-parameter.js"></script>
		<script type="text/javascript" src="scripts/story.js"></script>
		<link rel="stylesheet" type="text/css" href="css/main.css" />		
	</head>
	
	<body>	
		<p id="storyHeader" class="header">Story</p>
		<div id="breadcrumb"><?php echo storyBreadCrumb($story['story_id']);?></div>
				<div id="storyDetails" class="detailsHeader" style="display:table; margin-left:auto; margin-right:auto;">
				<div id="storyError" class="errordiv"></div>
			<div class="detailsHeaderLeft">
				<label>Story Name:</label><?php echo "<input id='storyName' type='text' value='$story[story_name]'/>"?>
			</div>
			<div class="detailsHeaderLeft">
				<label>Story Description:</label><?php echo "<input id='storyDesc' type='text' value='$story[story_desc]'/>"?>
			</div>
			<div class="detailsHeaderLeft">
				<label>Iteration ID:</label>
				<?php 
				echo "<input id='iterationID' type='text' value='$iterationId' disabled/>";
				?>
			</div>
			<div style="margin-top:120px; text-align: center;">
				<input type="button" value="Save" onclick="saveStory()"/>
				
			</div>
		</div>
		

		<div class="left">
			<p class="subheader">
				Story
			</p>
			<p>
				<ul>
					<?php 
						foreach($arrTasks as $taskList){
							echo "<p><a href=\"story.php?id=$taskList[story_id]&taskUrl=$taskList[task_id]\">$taskList[task_name]</a></p>";
							}
					?>
				</ul>
				<input type="button" value="Create New Task" onclick="createNewTask()" />
			</p>
		</div>
		
		<div class="right" id="taskDiv">
			<p class="subheader">
				Task
			</p>
			<div>
				<div id="taskError" class="errordiv"></div>
				<p>
					<label>Task Name:</label><?php echo "<input id='taskName' type='text' value='$task[task_name]'/>"?>
				</p>
				<p>
					<label>Task Description:</label><?php echo "<input id='taskDescription' type='text' value='$task[task_description]'/>"?>
				</p>
				<p>
					<label>Estimated Hours:</label><?php echo "<input id='estimatedHours' type='text' value='$task[estimated_hours]'/>"?>
				</p>
				<p>
					<label>Actual Hours:</label><?php echo "<input id='actualHours' type='text' value='$task[actual_hours]'/>"?>
				</p>
				<p>
					<label>Status:</label><?php echo "<input id='status' type='text' value='$task[status]'/>"?>
				</p>
				<p>
					<input type="button" value="Save Task" onclick="saveTask()" />
				</p>
			</div>
		</div>
	</body>
</html>